package com.lc.hongtai.adapter;

import android.content.Context;
import android.net.Uri;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.facebook.drawee.view.SimpleDraweeView;
import com.lc.hongtai.MyApplication;
import com.lc.hongtai.R;
import com.lc.hongtai.conn.JsonIndex;
import com.zcx.helper.bound.BoundViewHelper;

import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * Created by Administrator on 2017/4/7.
 */

public class IconAdapter  extends RecyclerView.Adapter<IconAdapter.ViewHolder>{

    private Context context;
    private List<JsonIndex.Info.Linek_img> list;


    public IconAdapter(Context context, List<JsonIndex.Info.Linek_img> list) {
        this.context = context;
        this.list = list;

    }
    public static class ViewHolder extends RecyclerView.ViewHolder {

        @Bind(R.id.img_icon)
        SimpleDraweeView img_icon;
        public ViewHolder(View view) {
            super(view);
            ButterKnife.bind(this, view);
        }
    }

    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = BoundViewHelper.boundView(this, MyApplication.scaleScreenHelper.loadView((ViewGroup) LayoutInflater.from(parent.getContext())
                .inflate(R.layout.item_icon, null)));

        IconAdapter.ViewHolder vh = new IconAdapter.ViewHolder(view);

        return vh;
    }

    @Override
    public void onBindViewHolder(ViewHolder holder, int position) {

//        holder.img_icon.setImageURI(Uri.parse("http://vhost106.zihaistar.com/UF/Uploads/Ad/20170327140802647.jpg"));
        holder.img_icon.setImageURI(Uri.parse(list.get(position).link_img));
    }

    @Override
    public int getItemCount() {
        return list.size();
    }


}
